/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

// fix sub nav on scroll
$(document).ready(function(){
    var $win = $(window)
      , $nav = $('.subnav')
      , navTop = $('.subnav').length && $('.subnav').offset().top
      , isFixed = 0
    processScroll()
    // hack sad times - holdover until rewrite for 2.1
    $(".subnav a").on('click', function () {
      var id=$(this).attr("href");
      var $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
      $body.animate({scrollTop: $(id).offset().top-70}, 500);
    })
    $win.on('scroll', processScroll)
     function processScroll() {
      var i, scrollTop = $win.scrollTop()
      if (scrollTop >= navTop && !isFixed) {
        isFixed = 1
        $nav.addClass('subnav-fixed')
      } else if (scrollTop <= navTop+15 && isFixed) {
        isFixed = 0
        $nav.removeClass('subnav-fixed')
      }
    }
   
})
